﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;
using Moq;

namespace AnyRepMembershipProvider.Tests.Mocks
{
    public class MockMembershipUserHelpers : IMembershipUserHelpers
    {
        public MembershipUser GetMembershipUserFromAnyRepMembershipUser(string ProviderName, AnyRepMembershipUser user)
        {
            // Initialize the shared Mock for MembershipUser Helpers Interface
            var membershipUserMock = new Mock<MembershipUser>();
            membershipUserMock.Setup(m => m.ProviderName).Returns(ProviderName);
            membershipUserMock.Setup(m => m.UserName).Returns(user.Username);
            membershipUserMock.Setup(m => m.ProviderUserKey).Returns(user.UserId);
            membershipUserMock.Setup(m => m.Email).Returns(user.Email);
            membershipUserMock.Setup(m => m.PasswordQuestion).Returns(user.PasswordQuestion);
            membershipUserMock.Setup(m => m.Comment).Returns(user.Comment);
            membershipUserMock.Setup(m => m.IsApproved).Returns(user.IsApproved);
            membershipUserMock.Setup(m => m.IsLockedOut).Returns(user.IsLockedOut);
            membershipUserMock.Setup(m => m.CreationDate).Returns(user.CreatedDate.GetValueOrDefault());
            membershipUserMock.Setup(m => m.LastLoginDate).Returns(user.LastLoginDate.GetValueOrDefault());
            membershipUserMock.Setup(m => m.LastActivityDate).Returns(user.LastActivityDate.GetValueOrDefault());
            membershipUserMock.Setup(m => m.LastPasswordChangedDate).Returns(user.LastPasswordChangedDate.GetValueOrDefault());
            membershipUserMock.Setup(m => m.LastLockoutDate).Returns(user.LastLockoutDate.GetValueOrDefault());

            return membershipUserMock.Object;
        }
    }
}
